package com.lumm.controller;

import com.lumm.model.Test;
import com.lumm.services.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/test")

public class TestController {

    @Autowired

    private TestService testService;

    @RequestMapping("query")
    public String query(@RequestParam(value = "username", required = true) String username, Model model) {
        Test test;
        test = testService.querybyUsername(username);
        model.addAttribute("test", test);
        System.out.println(test.getUsername());
        return "test";
    }

    @ResponseBody
    @RequestMapping("query2")
    public Test query2(@RequestParam(value = "username", required = true) String username, Model model) {
        Test test;
        test = testService.querybyUsername(username);
        //model.addAttribute("test", test);
        System.out.println(test.getUsername());
        return test;
    }


}
